<template>
  <div><button @click="redisDemo">请求后端redisTest接口</button></div>
  <div class="result-container"><span>{{ result }}</span></div>
</template>

<script>
import {redisDemo} from '@/api/redis'

export default {
  name: 'RedisDemo',
  data() {
    return {
      result: ''
    }
  },
  computed: {
    resultWithLineBreaks() {
      return this.result.replace(/\n/g, '<br>');
    },
  },
  methods: {
    redisDemo() {
      redisDemo().then(res => {
        this.result = this.result+ '\n'+res
      })
    }
  }
}
</script>
<style scoped>
.result-container {
  white-space: pre-wrap;
}

</style>